MACHINE ALLOCATION OPTIMIZATION

In [1]:
import pandas as pd
import re
In [2]:
import gurobipy as gp
In [3]:
data=pd.read_csv("/Users/ibironkeafolabi/Desktop/SMU_School_work /MBAN_5540/Casestudynumbers.csv")
In [4]:
years=[2013,2014,2015,2016,2017]
centers=list(data["Center"])
In [5]:
mac_year=[4,3,5,2,2]
In [6]:
#decision varible for each machine in each year for each center:
mac_var=[]
temp=1
for m,year in zip(mac_year,years):
  for t in range(m):
    for c in centers:
      print(f"M_{temp}_{c}_{year}")  
      mac_var.append(f"M_{temp}_{c}_{year}")    
    temp+=1
M_1_1_2013
M_1_2_2013
M_1_3_2013
M_1_4_2013
M_1_5_2013
M_1_6_2013
M_1_7_2013
M_1_8_2013
M_1_9_2013
M_1_10_2013
M_1_11_2013
M_1_12_2013
M_1_13_2013
M_1_14_2013
M_1_15_2013
M_1_16_2013
M_2_1_2013
M_2_2_2013
M_2_3_2013
M_2_4_2013
M_2_5_2013
M_2_6_2013
M_2_7_2013
M_2_8_2013
M_2_9_2013
M_2_10_2013
M_2_11_2013
M_2_12_2013
M_2_13_2013
M_2_14_2013
M_2_15_2013
M_2_16_2013
M_3_1_2013
M_3_2_2013
M_3_3_2013
M_3_4_2013
M_3_5_2013
M_3_6_2013
M_3_7_2013
M_3_8_2013
M_3_9_2013
M_3_10_2013
M_3_11_2013
M_3_12_2013
M_3_13_2013
M_3_14_2013
M_3_15_2013
M_3_16_2013
M_4_1_2013
M_4_2_2013
M_4_3_2013
M_4_4_2013
M_4_5_2013
M_4_6_2013
M_4_7_2013
M_4_8_2013
M_4_9_2013
M_4_10_2013
M_4_11_2013
M_4_12_2013
M_4_13_2013
M_4_14_2013
M_4_15_2013
M_4_16_2013
M_5_1_2014
M_5_2_2014
M_5_3_2014
M_5_4_2014
M_5_5_2014
M_5_6_2014
M_5_7_2014
M_5_8_2014
M_5_9_2014
M_5_10_2014
M_5_11_2014
M_5_12_2014
M_5_13_2014
M_5_14_2014
M_5_15_2014
M_5_16_2014
M_6_1_2014
M_6_2_2014
M_6_3_2014
M_6_4_2014
M_6_5_2014
M_6_6_2014
M_6_7_2014
M_6_8_2014
M_6_9_2014
M_6_10_2014
M_6_11_2014
M_6_12_2014
M_6_13_2014
M_6_14_2014
M_6_15_2014
M_6_16_2014
M_7_1_2014
M_7_2_2014
M_7_3_2014
M_7_4_2014
M_7_5_2014
M_7_6_2014
M_7_7_2014
M_7_8_2014
M_7_9_2014
M_7_10_2014
M_7_11_2014
M_7_12_2014
M_7_13_2014
M_7_14_2014
M_7_15_2014
M_7_16_2014
M_8_1_2015
M_8_2_2015
M_8_3_2015
M_8_4_2015
M_8_5_2015
M_8_6_2015
M_8_7_2015
M_8_8_2015
M_8_9_2015
M_8_10_2015
M_8_11_2015
M_8_12_2015
M_8_13_2015
M_8_14_2015
M_8_15_2015
M_8_16_2015
M_9_1_2015
M_9_2_2015
M_9_3_2015
M_9_4_2015
M_9_5_2015
M_9_6_2015
M_9_7_2015
M_9_8_2015
M_9_9_2015
M_9_10_2015
M_9_11_2015
M_9_12_2015
M_9_13_2015
M_9_14_2015
M_9_15_2015
M_9_16_2015
M_10_1_2015
M_10_2_2015
M_10_3_2015
M_10_4_2015
M_10_5_2015
M_10_6_2015
M_10_7_2015
M_10_8_2015
M_10_9_2015
M_10_10_2015
M_10_11_2015
M_10_12_2015
M_10_13_2015
M_10_14_2015
M_10_15_2015
M_10_16_2015
M_11_1_2015
M_11_2_2015
M_11_3_2015
M_11_4_2015
M_11_5_2015
M_11_6_2015
M_11_7_2015
M_11_8_2015
M_11_9_2015
M_11_10_2015
M_11_11_2015
M_11_12_2015
M_11_13_2015
M_11_14_2015
M_11_15_2015
M_11_16_2015
M_12_1_2015
M_12_2_2015
M_12_3_2015
M_12_4_2015
M_12_5_2015
M_12_6_2015
M_12_7_2015
M_12_8_2015
M_12_9_2015
M_12_10_2015
M_12_11_2015
M_12_12_2015
M_12_13_2015
M_12_14_2015
M_12_15_2015
M_12_16_2015
M_13_1_2016
M_13_2_2016
M_13_3_2016
M_13_4_2016
M_13_5_2016
M_13_6_2016
M_13_7_2016
M_13_8_2016
M_13_9_2016
M_13_10_2016
M_13_11_2016
M_13_12_2016
M_13_13_2016
M_13_14_2016
M_13_15_2016
M_13_16_2016
M_14_1_2016
M_14_2_2016
M_14_3_2016
M_14_4_2016
M_14_5_2016
M_14_6_2016
M_14_7_2016
M_14_8_2016
M_14_9_2016
M_14_10_2016
M_14_11_2016
M_14_12_2016
M_14_13_2016
M_14_14_2016
M_14_15_2016
M_14_16_2016
M_15_1_2017
M_15_2_2017
M_15_3_2017
M_15_4_2017
M_15_5_2017
M_15_6_2017
M_15_7_2017
M_15_8_2017
M_15_9_2017
M_15_10_2017
M_15_11_2017
M_15_12_2017
M_15_13_2017
M_15_14_2017
M_15_15_2017
M_15_16_2017
M_16_1_2017
M_16_2_2017
M_16_3_2017
M_16_4_2017
M_16_5_2017
M_16_6_2017
M_16_7_2017
M_16_8_2017
M_16_9_2017
M_16_10_2017
M_16_11_2017
M_16_12_2017
M_16_13_2017
M_16_14_2017
M_16_15_2017
M_16_16_2017
In [7]:
por_var=[]
for y in years:
  for c in centers:
    for i in [1,2]:
      por_var.append(f"P_{i}_{c}_{y}")
In [8]:
demand={}

for c in centers:
  for y in years:
    demand[f"{c}_{y}"]=int(data[data["Center"]==c][f"{y}"])
In [9]:
empty_room=[0,1,0,2,1,1,2,1,1,1,0,1,1,1,3,0] # Centers with rooms ready for a machine installation
In [10]:
ava_mac=[1,5,6,4,11,9,6,5,2,3,13,12,16,3,3,3] # Number of available machines in each center at the beginning of 2013
In [11]:
model= gp.Model()
Set parameter Username
Academic license - for non-commercial use only - expires 2024-01-12
In [12]:
added_mac_var={}
for m in mac_var:
  added_mac_var[m]=model.addVar(name=m,vtype='B')
added_por_var={}
for p in por_var:
  added_por_var[p]=model.addVar(name=p,vtype='B')
In [13]:
#cal_mach_each center_each year:
n={}
por_n={}
for c in centers:
  for y in years:
    r = re.compile(f".*_{c}_{y}")
    newlist = list(filter(r.match, added_mac_var))
    temp=0
    print(newlist)
    for t in newlist:
      temp=temp+added_mac_var[t]
    n[f"n_{c}_{y}"] = temp

    newlist = list(filter(r.match, added_por_var))
    temp=0
    for t in newlist:
      temp=temp+added_por_var[t]
    # print(newlist)
    por_n[f"pn_{c}_{y}"] = temp
['M_1_1_2013', 'M_2_1_2013', 'M_3_1_2013', 'M_4_1_2013']
['M_5_1_2014', 'M_6_1_2014', 'M_7_1_2014']
['M_8_1_2015', 'M_9_1_2015', 'M_10_1_2015', 'M_11_1_2015', 'M_12_1_2015']
['M_13_1_2016', 'M_14_1_2016']
['M_15_1_2017', 'M_16_1_2017']
['M_1_2_2013', 'M_2_2_2013', 'M_3_2_2013', 'M_4_2_2013']
['M_5_2_2014', 'M_6_2_2014', 'M_7_2_2014']
['M_8_2_2015', 'M_9_2_2015', 'M_10_2_2015', 'M_11_2_2015', 'M_12_2_2015']
['M_13_2_2016', 'M_14_2_2016']
['M_15_2_2017', 'M_16_2_2017']
['M_1_3_2013', 'M_2_3_2013', 'M_3_3_2013', 'M_4_3_2013']
['M_5_3_2014', 'M_6_3_2014', 'M_7_3_2014']
['M_8_3_2015', 'M_9_3_2015', 'M_10_3_2015', 'M_11_3_2015', 'M_12_3_2015']
['M_13_3_2016', 'M_14_3_2016']
['M_15_3_2017', 'M_16_3_2017']
['M_1_4_2013', 'M_2_4_2013', 'M_3_4_2013', 'M_4_4_2013']
['M_5_4_2014', 'M_6_4_2014', 'M_7_4_2014']
['M_8_4_2015', 'M_9_4_2015', 'M_10_4_2015', 'M_11_4_2015', 'M_12_4_2015']
['M_13_4_2016', 'M_14_4_2016']
['M_15_4_2017', 'M_16_4_2017']
['M_1_5_2013', 'M_2_5_2013', 'M_3_5_2013', 'M_4_5_2013']
['M_5_5_2014', 'M_6_5_2014', 'M_7_5_2014']
['M_8_5_2015', 'M_9_5_2015', 'M_10_5_2015', 'M_11_5_2015', 'M_12_5_2015']
['M_13_5_2016', 'M_14_5_2016']
['M_15_5_2017', 'M_16_5_2017']
['M_1_6_2013', 'M_2_6_2013', 'M_3_6_2013', 'M_4_6_2013']
['M_5_6_2014', 'M_6_6_2014', 'M_7_6_2014']
['M_8_6_2015', 'M_9_6_2015', 'M_10_6_2015', 'M_11_6_2015', 'M_12_6_2015']
['M_13_6_2016', 'M_14_6_2016']
['M_15_6_2017', 'M_16_6_2017']
['M_1_7_2013', 'M_2_7_2013', 'M_3_7_2013', 'M_4_7_2013']
['M_5_7_2014', 'M_6_7_2014', 'M_7_7_2014']
['M_8_7_2015', 'M_9_7_2015', 'M_10_7_2015', 'M_11_7_2015', 'M_12_7_2015']
['M_13_7_2016', 'M_14_7_2016']
['M_15_7_2017', 'M_16_7_2017']
['M_1_8_2013', 'M_2_8_2013', 'M_3_8_2013', 'M_4_8_2013']
['M_5_8_2014', 'M_6_8_2014', 'M_7_8_2014']
['M_8_8_2015', 'M_9_8_2015', 'M_10_8_2015', 'M_11_8_2015', 'M_12_8_2015']
['M_13_8_2016', 'M_14_8_2016']
['M_15_8_2017', 'M_16_8_2017']
['M_1_9_2013', 'M_2_9_2013', 'M_3_9_2013', 'M_4_9_2013']
['M_5_9_2014', 'M_6_9_2014', 'M_7_9_2014']
['M_8_9_2015', 'M_9_9_2015', 'M_10_9_2015', 'M_11_9_2015', 'M_12_9_2015']
['M_13_9_2016', 'M_14_9_2016']
['M_15_9_2017', 'M_16_9_2017']
['M_1_10_2013', 'M_2_10_2013', 'M_3_10_2013', 'M_4_10_2013']
['M_5_10_2014', 'M_6_10_2014', 'M_7_10_2014']
['M_8_10_2015', 'M_9_10_2015', 'M_10_10_2015', 'M_11_10_2015', 'M_12_10_2015']
['M_13_10_2016', 'M_14_10_2016']
['M_15_10_2017', 'M_16_10_2017']
['M_1_11_2013', 'M_2_11_2013', 'M_3_11_2013', 'M_4_11_2013']
['M_5_11_2014', 'M_6_11_2014', 'M_7_11_2014']
['M_8_11_2015', 'M_9_11_2015', 'M_10_11_2015', 'M_11_11_2015', 'M_12_11_2015']
['M_13_11_2016', 'M_14_11_2016']
['M_15_11_2017', 'M_16_11_2017']
['M_1_12_2013', 'M_2_12_2013', 'M_3_12_2013', 'M_4_12_2013']
['M_5_12_2014', 'M_6_12_2014', 'M_7_12_2014']
['M_8_12_2015', 'M_9_12_2015', 'M_10_12_2015', 'M_11_12_2015', 'M_12_12_2015']
['M_13_12_2016', 'M_14_12_2016']
['M_15_12_2017', 'M_16_12_2017']
['M_1_13_2013', 'M_2_13_2013', 'M_3_13_2013', 'M_4_13_2013']
['M_5_13_2014', 'M_6_13_2014', 'M_7_13_2014']
['M_8_13_2015', 'M_9_13_2015', 'M_10_13_2015', 'M_11_13_2015', 'M_12_13_2015']
['M_13_13_2016', 'M_14_13_2016']
['M_15_13_2017', 'M_16_13_2017']
['M_1_14_2013', 'M_2_14_2013', 'M_3_14_2013', 'M_4_14_2013']
['M_5_14_2014', 'M_6_14_2014', 'M_7_14_2014']
['M_8_14_2015', 'M_9_14_2015', 'M_10_14_2015', 'M_11_14_2015', 'M_12_14_2015']
['M_13_14_2016', 'M_14_14_2016']
['M_15_14_2017', 'M_16_14_2017']
['M_1_15_2013', 'M_2_15_2013', 'M_3_15_2013', 'M_4_15_2013']
['M_5_15_2014', 'M_6_15_2014', 'M_7_15_2014']
['M_8_15_2015', 'M_9_15_2015', 'M_10_15_2015', 'M_11_15_2015', 'M_12_15_2015']
['M_13_15_2016', 'M_14_15_2016']
['M_15_15_2017', 'M_16_15_2017']
['M_1_16_2013', 'M_2_16_2013', 'M_3_16_2013', 'M_4_16_2013']
['M_5_16_2014', 'M_6_16_2014', 'M_7_16_2014']
['M_8_16_2015', 'M_9_16_2015', 'M_10_16_2015', 'M_11_16_2015', 'M_12_16_2015']
['M_13_16_2016', 'M_14_16_2016']
['M_15_16_2017', 'M_16_16_2017']
In [14]:
obj=[]
for y in years:
  for c in centers:
    d=demand[f"{c}_{y}"]
    his_mac=ava_mac[c-1]
    # print(his_mac)
    total_machine=his_mac
    total_port=por_n[f"pn_{c}_{y}"]
    temp_y=y
    while temp_y>=2013:
      total_machine=total_machine+n[f"n_{c}_{temp_y}"]
      # print(f"n_{c}_{temp_y}")
      # print(n[f"n_{c}_{temp_y}"])
      temp_y-=1
    # print(total_machine)
    untread = (d - (426*(total_machine+total_port)))**2
    print(untread)
    obj.append(untread)
In [15]:
total_machine_per_center=[]

for c in centers:
  t=0
  for y in years:
    for m in range(1,17):
      if f"M_{m}_{c}_{y}" in added_mac_var.keys():
        t=t+added_mac_var[f"M_{m}_{c}_{y}"]
  print(t)
  total_machine_per_center.append(t)
In [16]:
for e,t in zip(empty_room,total_machine_per_center):
  model.addConstr( t <= e)
In [17]:
total_machine_per_year=[]
for y in years:
    r = re.compile(f".*_{y}")
    newlist = list(filter(r.match, added_mac_var.keys()))
    print(newlist)
    temp=0
    for i in newlist:
      temp=temp+added_mac_var[i]

    total_machine_per_year.append(temp)
print(total_machine_per_year)
['M_1_1_2013', 'M_1_2_2013', 'M_1_3_2013', 'M_1_4_2013', 'M_1_5_2013', 'M_1_6_2013', 'M_1_7_2013', 'M_1_8_2013', 'M_1_9_2013', 'M_1_10_2013', 'M_1_11_2013', 'M_1_12_2013', 'M_1_13_2013', 'M_1_14_2013', 'M_1_15_2013', 'M_1_16_2013', 'M_2_1_2013', 'M_2_2_2013', 'M_2_3_2013', 'M_2_4_2013', 'M_2_5_2013', 'M_2_6_2013', 'M_2_7_2013', 'M_2_8_2013', 'M_2_9_2013', 'M_2_10_2013', 'M_2_11_2013', 'M_2_12_2013', 'M_2_13_2013', 'M_2_14_2013', 'M_2_15_2013', 'M_2_16_2013', 'M_3_1_2013', 'M_3_2_2013', 'M_3_3_2013', 'M_3_4_2013', 'M_3_5_2013', 'M_3_6_2013', 'M_3_7_2013', 'M_3_8_2013', 'M_3_9_2013', 'M_3_10_2013', 'M_3_11_2013', 'M_3_12_2013', 'M_3_13_2013', 'M_3_14_2013', 'M_3_15_2013', 'M_3_16_2013', 'M_4_1_2013', 'M_4_2_2013', 'M_4_3_2013', 'M_4_4_2013', 'M_4_5_2013', 'M_4_6_2013', 'M_4_7_2013', 'M_4_8_2013', 'M_4_9_2013', 'M_4_10_2013', 'M_4_11_2013', 'M_4_12_2013', 'M_4_13_2013', 'M_4_14_2013', 'M_4_15_2013', 'M_4_16_2013']
['M_5_1_2014', 'M_5_2_2014', 'M_5_3_2014', 'M_5_4_2014', 'M_5_5_2014', 'M_5_6_2014', 'M_5_7_2014', 'M_5_8_2014', 'M_5_9_2014', 'M_5_10_2014', 'M_5_11_2014', 'M_5_12_2014', 'M_5_13_2014', 'M_5_14_2014', 'M_5_15_2014', 'M_5_16_2014', 'M_6_1_2014', 'M_6_2_2014', 'M_6_3_2014', 'M_6_4_2014', 'M_6_5_2014', 'M_6_6_2014', 'M_6_7_2014', 'M_6_8_2014', 'M_6_9_2014', 'M_6_10_2014', 'M_6_11_2014', 'M_6_12_2014', 'M_6_13_2014', 'M_6_14_2014', 'M_6_15_2014', 'M_6_16_2014', 'M_7_1_2014', 'M_7_2_2014', 'M_7_3_2014', 'M_7_4_2014', 'M_7_5_2014', 'M_7_6_2014', 'M_7_7_2014', 'M_7_8_2014', 'M_7_9_2014', 'M_7_10_2014', 'M_7_11_2014', 'M_7_12_2014', 'M_7_13_2014', 'M_7_14_2014', 'M_7_15_2014', 'M_7_16_2014']
['M_8_1_2015', 'M_8_2_2015', 'M_8_3_2015', 'M_8_4_2015', 'M_8_5_2015', 'M_8_6_2015', 'M_8_7_2015', 'M_8_8_2015', 'M_8_9_2015', 'M_8_10_2015', 'M_8_11_2015', 'M_8_12_2015', 'M_8_13_2015', 'M_8_14_2015', 'M_8_15_2015', 'M_8_16_2015', 'M_9_1_2015', 'M_9_2_2015', 'M_9_3_2015', 'M_9_4_2015', 'M_9_5_2015', 'M_9_6_2015', 'M_9_7_2015', 'M_9_8_2015', 'M_9_9_2015', 'M_9_10_2015', 'M_9_11_2015', 'M_9_12_2015', 'M_9_13_2015', 'M_9_14_2015', 'M_9_15_2015', 'M_9_16_2015', 'M_10_1_2015', 'M_10_2_2015', 'M_10_3_2015', 'M_10_4_2015', 'M_10_5_2015', 'M_10_6_2015', 'M_10_7_2015', 'M_10_8_2015', 'M_10_9_2015', 'M_10_10_2015', 'M_10_11_2015', 'M_10_12_2015', 'M_10_13_2015', 'M_10_14_2015', 'M_10_15_2015', 'M_10_16_2015', 'M_11_1_2015', 'M_11_2_2015', 'M_11_3_2015', 'M_11_4_2015', 'M_11_5_2015', 'M_11_6_2015', 'M_11_7_2015', 'M_11_8_2015', 'M_11_9_2015', 'M_11_10_2015', 'M_11_11_2015', 'M_11_12_2015', 'M_11_13_2015', 'M_11_14_2015', 'M_11_15_2015', 'M_11_16_2015', 'M_12_1_2015', 'M_12_2_2015', 'M_12_3_2015', 'M_12_4_2015', 'M_12_5_2015', 'M_12_6_2015', 'M_12_7_2015', 'M_12_8_2015', 'M_12_9_2015', 'M_12_10_2015', 'M_12_11_2015', 'M_12_12_2015', 'M_12_13_2015', 'M_12_14_2015', 'M_12_15_2015', 'M_12_16_2015']
['M_13_1_2016', 'M_13_2_2016', 'M_13_3_2016', 'M_13_4_2016', 'M_13_5_2016', 'M_13_6_2016', 'M_13_7_2016', 'M_13_8_2016', 'M_13_9_2016', 'M_13_10_2016', 'M_13_11_2016', 'M_13_12_2016', 'M_13_13_2016', 'M_13_14_2016', 'M_13_15_2016', 'M_13_16_2016', 'M_14_1_2016', 'M_14_2_2016', 'M_14_3_2016', 'M_14_4_2016', 'M_14_5_2016', 'M_14_6_2016', 'M_14_7_2016', 'M_14_8_2016', 'M_14_9_2016', 'M_14_10_2016', 'M_14_11_2016', 'M_14_12_2016', 'M_14_13_2016', 'M_14_14_2016', 'M_14_15_2016', 'M_14_16_2016']
['M_15_1_2017', 'M_15_2_2017', 'M_15_3_2017', 'M_15_4_2017', 'M_15_5_2017', 'M_15_6_2017', 'M_15_7_2017', 'M_15_8_2017', 'M_15_9_2017', 'M_15_10_2017', 'M_15_11_2017', 'M_15_12_2017', 'M_15_13_2017', 'M_15_14_2017', 'M_15_15_2017', 'M_15_16_2017', 'M_16_1_2017', 'M_16_2_2017', 'M_16_3_2017', 'M_16_4_2017', 'M_16_5_2017', 'M_16_6_2017', 'M_16_7_2017', 'M_16_8_2017', 'M_16_9_2017', 'M_16_10_2017', 'M_16_11_2017', 'M_16_12_2017', 'M_16_13_2017', 'M_16_14_2017', 'M_16_15_2017', 'M_16_16_2017']
In [18]:
for ma,ty in zip(mac_year,total_machine_per_year):
  model.addConstr( ty == ma )
In [19]:
total_por_machine_per_year=[]
for y in years:
    r = re.compile(f".*_{y}")
    newlist = list(filter(r.match, added_por_var.keys()))
    # print(newlist)
    temp_p1=0
    temp_p2=0
    for i in newlist:
      if i[:3] == "P_1":
        # print("p1")
        temp_p1=temp_p1+added_por_var[i]
      else:
        # print("p2")
        temp_p2=temp_p2+added_por_var[i]
    # print(temp_p1)
    # print(temp_p2)
    total_por_machine_per_year.append(temp_p1)
    total_por_machine_per_year.append(temp_p2)
    # print(total_por_machine_per_year)
print(total_por_machine_per_year)
In [20]:
len(total_por_machine_per_year)
Out[20]:
10
In [21]:
for tpy in total_por_machine_per_year:
  model.addConstr( tpy == 1 )
In [22]:
each_mac_once=[]
for m in range(1,17):
    r = re.compile(f"^M_{m}_")
    newlist = list(filter(r.match, added_mac_var.keys()))
    # print(newlist)
    temp=0
    for i in newlist:
      temp=temp+added_mac_var[i]
    each_mac_once.append(temp)
print(each_mac_once)
In [23]:
for em in each_mac_once:
  model.addConstr( em == 1 )
In [24]:
model.setObjective(sum(obj), gp.GRB.MINIMIZE)
model.update()
model.optimize()
Gurobi Optimizer version 10.0.1 build v10.0.1rc0 (mac64[rosetta2])

CPU model: Apple M1
Thread count: 8 physical cores, 8 logical processors, using up to 8 threads

Optimize a model with 47 rows, 416 columns and 928 nonzeros
Model fingerprint: 0xc26141de
Model has 4112 quadratic objective terms
Variable types: 0 continuous, 416 integer (416 binary)
Coefficient statistics:
  Matrix range     [1e+00, 1e+00]
  Objective range  [6e+03, 7e+06]
  QObjective range [4e+05, 4e+06]
  Bounds range     [1e+00, 1e+00]
  RHS range        [1e+00, 5e+00]
Found heuristic solution: objective 1.921916e+07
Presolve removed 9 rows and 64 columns
Presolve time: 0.02s
Presolved: 38 rows, 352 columns, 544 nonzeros
Presolved model has 3144 quadratic objective terms
Variable types: 0 continuous, 352 integer (352 binary)
Found heuristic solution: objective 1.126063e+07

Root relaxation: objective 4.957392e+06, 222 iterations, 0.00 seconds (0.00 work units)

    Nodes    |    Current Node    |     Objective Bounds      |     Work
 Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time

     0     0 4957391.92    0   64 1.1261e+07 4957391.92  56.0%     -    0s
H    0     0                    5906665.0000 4957391.92  16.1%     -    0s
H    0     0                    5763529.0000 4957391.92  14.0%     -    0s
     0     0 4957391.92    0   64 5763529.00 4957391.92  14.0%     -    0s
H    0     0                    5714113.0000 4957391.92  13.2%     -    0s
     0     2 4957391.92    0   64 5714113.00 4957391.92  13.2%     -    0s
 128649 33654     cutoff   48      5714113.00 5563005.68  2.64%   6.0    5s
 283056 16971     cutoff   40      5714113.00 5677365.61  0.64%   5.5   10s

Explored 318153 nodes (1719787 simplex iterations) in 11.24 seconds (11.71 work units)
Thread count was 8 (of 8 available processors)

Solution count 5: 5.71411e+06 5.76353e+06 5.90666e+06 ... 1.92192e+07

Optimal solution found (tolerance 1.00e-04)
Best objective 5.714113000000e+06, best bound 5.714113000000e+06, gap 0.0000%
In [25]:
def print_model(model):
    for i in model.getVars():
        if i.x == 1:
            print(i.VarName, i.x)
    print("Solution:", model.objVal)
In [26]:
print_model(model)
M_1_15_2013 1.0
M_2_15_2013 1.0
M_3_4_2013 1.0
M_4_15_2013 1.0
M_5_6_2014 1.0
M_6_4_2014 1.0
M_7_14_2014 1.0
M_8_12_2015 1.0
M_9_13_2015 1.0
M_10_9_2015 1.0
M_11_7_2015 1.0
M_12_10_2015 1.0
M_13_2_2016 1.0
M_14_5_2016 1.0
M_15_7_2017 1.0
M_16_8_2017 1.0
P_1_6_2013 1.0
P_2_16_2013 1.0
P_2_3_2014 1.0
P_1_16_2014 1.0
P_1_3_2015 1.0
P_2_16_2015 1.0
P_1_3_2016 1.0
P_2_15_2016 1.0
P_1_3_2017 1.0
P_2_15_2017 1.0
Solution: 5714113.0
In [27]:
model.write("model_Group1.lp")